import { Button, Form, Input, Select, DatePicker, Space } from 'antd';
import React from 'react';
import './css/search.scss';
function Search(props: any) {
  const { Option } = Select;
  const { RangePicker } = DatePicker;
  // 父组件传的事件
  // const handleChange = (value) => {
  //     console.log(`selected ${value}`);
  // };
  // 父组件的事件
  // const onChange = (date, dateString) => {
  //     console.log(date, dateString);
  // };
  return (
    <Form
      name="basic"
      labelCol={{ span: 8 }}
      wrapperCol={{ span: 16 }}
      initialValues={{ remember: true }}
      autoComplete="off"
    >
      {props.list.map((item: any, index: number) => {
        return (
          <Form.Item
            key={index}
            label={item.lable}
            name={item.prop}
            rules={[{ required: true, message: 'Please input your 11!' }]}
          >
            {item.type === 'input' ? (
              <Input style={{ width: props.Inputwidth }} />
            ) : item.type === 'date' ? (
              <Space direction="vertical" size={32} style={{ width: props.Datewidth }}>
                <RangePicker />
              </Space>
            ) : item.type === 'select' ? (
              <div>
                <Select
                  defaultValue="请选择"
                  style={{
                    width: props.Selectwidth,
                  }}
                  onChange={props.handleChange}
                >
                  {item.options.map((res: any, i: any) => {
                    return (
                      <Option key={i} value={res.sex}>
                        {res.sex}
                      </Option>
                    );
                  })}
                </Select>
              </div>
            ) : (
              ''
            )}
          </Form.Item>
        );
      })}

      <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
        <Button type="primary" htmlType="submit" onClick={props.change}>
          搜索
        </Button>
      </Form.Item>
    </Form>
  );
}
export default Search;
